<?php


namespace App\Api\Fcjd;
use PhalApi\Api;
use PhalApi\Exception\BadRequestException;

/**
 * 非常检单-中控端版本更新
 *
 * @author: dogstar <chanzonghuang@gmail.com> 2014-10-04
 */
class PhoneAdmin extends Api
{

    public function getRules()
    {
        return array(
            'GetPhoneAdminInfo'=> array(
                'name' => array('name' => 'name', 'type' => 'string', 'require' => false, 'desc' => '名称'),
                'channel' => array('name' => 'channel', 'type' => 'string', 'require' => false, 'desc' => '名称'),
            ),
        );
    }


    /**
     * 获取PhoneAdmin更新信息
     * @desc 获取PhoneAdmin更新信息
     * @return array data 获取PhoneAdmin更新信息
     * @exception 400 非法请求，参数传递错误
     */

    public function GetPhoneAdminInfo()
    { 
        $where = array(
            'state' => 1,
        );
        if($this->name){
            $where['name'] = $this->name;
        }
        if($this->channel){
            $where['channel'] = $this->channel; 
        }

        // return $where;

        $data = \PhalApi\DI()
            ->notorm
            ->phone_admin
            ->select('*')
            ->where($where)
            ->order('id desc')
            ->fetchOne();
        
        return $data;
    }

    
}
